<#import './common.ftl' as com>
<@com.page title="注册" bodyBGColor="darkcyan">
    <div>
        <div style="display: flex; justify-content: center;align-content: center;margin-top: 100px;">
            <img src="img/logo.png"  width="200" height="100"/>
        </div>
        <form role='form' style="padding-top: 100px;" class="top form-horizontal">
            <div class="form-group" style="align-items: center; display: flex;">
                <label class="col-md-4 control-label" for="password">昵称:</label>
                <div class="col-md-4" ">
                <input type="text" class="form-control " id="nickname"/>
            </div>
            <label class="col-md-4 " style="color: red;padding-left: 0; ">(*必填)</label>
    </div>
			<div class="form-group" style="align-items: center; display: flex;">
                <label class="control-label col-md-4" for="account">账号:</label>
                <div class=" col-md-4 ">
                    <input type="text" id="account" class="form-control " />
                </div>
                <label class="col-md-4 " style="color: red;padding-left: 0;">(*必填)</label>
            </div>
			<div class="form-group" style="align-items: center; display: flex;">
                <label class="col-md-4 control-label" for="password">密码:</label>
                <div class="col-md-4"">
                <input type="password" class="form-control" id="password"/>
            </div>
				<label class="col-md-4 " style="color: red;padding-left: 0;">(*必填)</label>
			</div>
			<div class="form-group" style="align-items: center; display: flex;">
                <label class="col-md-4 control-label" for="password">确认密码:</label>
                <div class="col-md-4"">
                <input type="password" class="form-control" id="nextpassword"/>
            </div>
				<label class="col-md-4 " style="color: red;padding-left: 0;">(*必填)</label>
			</div>
			<div class="form-group" style="margin-top: 100px;">
                <div class="col-md-offset-4 col-md-4">
                    <button class="btn btn-primary center-block" id="register" type="button"> 注册 </button>
                </div>

            </div>
		</form>
	</div>
</@com.page>
<script>
	$("#register").click(()=>{
		var counter=$('#account').val()
		var password=$('#password').val()
		var nickname=$('#nickname').val()
		var nextpassword=$('#nextpassword').val()
		if(password==nextpassword){
			jsJson().postrequest('http://localhost:8080/register',{
			'accont':counter,
			'password':password,
			'nickname':nickname
		},event=>{
			alert(event.msg)
			if(event.code==200){
				window.location.href="./login"
			}
		})
			
		}else{
			alert('两次密码不一样')
		}
		
	})
</script>